import java.util.HashMap;
import java.util.Map;

public class addsum {

    class Solution1 {
        public int[] twoSum(int[] nums, int target) {
            for (int i = 0; i < nums.length; i++) {
                for (int j = i+1; j < nums.length; j++) {
                    if (nums[i]==target-nums[j]){
                        return new int[]{i,j};
                    }
                }
            }
            return new int[0];
        }
    }

    class Solution2 {
        public int[] twoSum(int[] nums, int target) {
            Map<Integer,Integer> hash=new HashMap<>();
            for (int i = 0; i < nums.length; i++) {
                if (hash.containsKey(target-nums[i])){
                    return new int[]{hash.get(target - nums[i]), i};
                    }
                hash.put(nums[i], i);
                }
            return new int[0];
            }
        }
    }

